package part1;

/**
 * <p>Title: Project 11 part 1</p>
 * <p>Description: CS 235 Project #11 pt. 1
 *       Shows how to set up code for drag-and-drop in Swing.<br/>
 *       We also look at various Swing components.</p>
 *       
 * Part1 class is a standalone window class
 * 
 * @author Anthony Varghese
 * @date   February 5th 2012
 * @version 1.0
 */

import java.awt.Color;

import javax.swing.JTextArea;
import javax.swing.JTextField;

public class Part1 extends javax.swing.JFrame {
	/**
	 * Data members
	 */
	private static final long serialVersionUID = 1L;

	private final int WINDOW_X_ORIGIN = 100;
	private final int WINDOW_Y_ORIGIN = 100;
	private final int WINDOW_WIDTH    = 400;
	private final int WINDOW_HEIGHT   = 300;

	private JTextField tfield;
	private final int TEXTFIELD_X_ORIGIN = 50;
	private final int TEXTFIELD_Y_ORIGIN = 50;
	private final int TEXTFIELD_WIDTH    = 100;
	private final int TEXTFIELD_HEIGHT   = 35;

	private JTextArea  tarea;
	private final int TEXTAREA_X_ORIGIN = 200;
	private final int TEXTAREA_Y_ORIGIN = 50;
	private final int TEXTAREA_WIDTH    = 150;
	private final int TEXTAREA_HEIGHT   = 150;
	private final String TEXTAREA_STRING = "Click and Clack\nRomeo and Juliet\nShake and Bake\n"+
											"Abbott and Costello\nRogers and Astaire\nBert and Ernie";

	public Part1(String title){
		super( title );
		setBounds( WINDOW_X_ORIGIN, WINDOW_Y_ORIGIN, WINDOW_WIDTH, WINDOW_HEIGHT);
		setDefaultCloseOperation(EXIT_ON_CLOSE);
		setLayout( null );
		
		tfield = new JTextField( title );
		tfield.setBounds(TEXTFIELD_X_ORIGIN, TEXTFIELD_Y_ORIGIN, TEXTFIELD_WIDTH, TEXTFIELD_HEIGHT);
		add( tfield );
		
		tarea = new JTextArea( TEXTAREA_STRING );
		tarea.setBounds(TEXTAREA_X_ORIGIN, TEXTAREA_Y_ORIGIN, TEXTAREA_WIDTH, TEXTAREA_HEIGHT);
		tarea.setBorder( javax.swing.BorderFactory.createLineBorder(Color.BLUE) );
		add( tarea );
		
		setVisible( true );
	}
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new Part1("Drag and drop");	
	}
}
